#include "Com_Util.h"
#include "Dri_Timer_2.h"

#include "Int_Motor.h"
#include "Int_Bluetooth.h"
#include "Int_OLED.h"
#include "Int_Radio.h"
#include "Int_OLED_Data.h"
#include "Int_Patrol.h"
#include "Int_One_Key.h"

#include "App_Bluetooth.h"
#include "App_Obstacle.h"
#include "App_Patrol.h"

void main()
{
    u8 key1_state;
    char error_weight = 0;
    // char str[17];
    Dri_Timer2_Init();

    // 开始屏幕
    Int_OLED_Start();
    Int_OLED_Clear();
    // 初始化雷达
    Int_Radio_Init();
    // 初始化马达
    Int_Motor_Init();
    // 初始化蓝牙
    Int_Bluetooth_Init();
    App_Obstacle_Init();
    
    Int_Key_Init();

    while (1) {
        //  App_Obstacle_Controler();
        // App_Bluetooth_Controller();

        //  Delay_ms(1000);
        //  Int_Bluetooth_find_Name();
        // error_weight = Int_Patrol_Init();
        // sprintf(str, "%d ", (int)error_weight);
        // Int_OLED_Data_Str_Show(str, 0, 0);
        // App_Patrol_Controller();

        // key1_state = Int_Key1_State();
        // if (key1_state == 1) {
        //     //  0 = 没有变化, 1= 按下去, 2 = 抬起来
        //     Int_OLED_Data_Str_Show("KEY DOWN   ", 0, 0);
        // } else if (key1_state == 2) {
        //     Int_OLED_Data_Str_Show("KEY UP    ", 0, 0);
        // } else {
        //     Int_OLED_Data_Str_Show("KEY NO!!!!", 0, 0);
        // }
    }
}
